1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */
28 module derelict.anttweakbar.anttweakbar;
29 
30 public
31 {
32     import derelict.anttweakbar.types;
33     import derelict.anttweakbar.functions;
34 }
35 
36 private
37 {
38     import derelict.util.loader;
39     import derelict.util.system;
40 
41     static if(Derelict_OS_Windows)
42 		version(Win64) enum libNames = "AntTweakBar64.dll";
43 		else enum libNames = "AntTweakBar.dll";
44     else static if(Derelict_OS_Mac)
45         enum libNames = "libAntTweakBar.dylib";
46     else static if(Derelict_OS_Posix)
47         enum libNames = "libAntTweakBar.so,libAntTweakBar.so,/usr/local/lib/libAntTweakBar.so,/usr/local/lib/libAntTweakBar.so";
48     else
49         static assert(0, "Need to implement AntTweakBar libNames for this operating system.");
50 }
51 
52 class DerelictAntTweakBarLoader : SharedLibLoader
53 {
54     protected
55     {
56         override void loadSymbols()
57         {
58 			bindFunc(cast(void**)&TwNewBar                   , "_TwNewBar@4");
59 			bindFunc(cast(void**)&TwDeleteBar                , "_TwDeleteBar@4");
60 			bindFunc(cast(void**)&TwDeleteAllBars            , "_TwDeleteAllBars@0");
61 			bindFunc(cast(void**)&TwSetTopBar                , "_TwSetTopBar@4");
62 			bindFunc(cast(void**)&TwGetTopBar                , "_TwGetTopBar@0");
63 			bindFunc(cast(void**)&TwSetBottomBar             , "_TwSetBottomBar@4");
64 			bindFunc(cast(void**)&TwGetBottomBar             , "_TwGetBottomBar@0");
65 			bindFunc(cast(void**)&TwGetBarName               , "_TwGetBarName@4");
66 			bindFunc(cast(void**)&TwGetBarCount              , "_TwGetBarCount@0");
67 			bindFunc(cast(void**)&TwGetBarByIndex            , "_TwGetBarByIndex@4");
68 			bindFunc(cast(void**)&TwGetBarByName             , "_TwGetBarByName@4");
69 			bindFunc(cast(void**)&TwRefreshBar               , "_TwRefreshBar@4");
70 			bindFunc(cast(void**)&TwAddVarRW                 , "_TwAddVarRW@20");
71 			bindFunc(cast(void**)&TwAddVarRO                 , "_TwAddVarRO@20");
72 			bindFunc(cast(void**)&TwAddVarCB                 , "_TwAddVarCB@28");
73 			bindFunc(cast(void**)&TwAddButton                , "_TwAddButton@20");
74 			bindFunc(cast(void**)&TwAddSeparator             , "_TwAddSeparator@12");
75 			bindFunc(cast(void**)&TwRemoveVar                , "_TwRemoveVar@8");
76 			bindFunc(cast(void**)&TwRemoveAllVars            , "_TwRemoveAllVars@4");
77 			bindFunc(cast(void**)&TwDefine                   , "_TwDefine@4");
78 			bindFunc(cast(void**)&TwDefineEnum               , "_TwDefineEnum@12");
79 			bindFunc(cast(void**)&TwDefineEnumFromString     , "_TwDefineEnumFromString@8");
80 			bindFunc(cast(void**)&TwDefineStruct             , "_TwDefineStruct@24");
81 			bindFunc(cast(void**)&TwCopyCDStringToClientFunc , "_TwCopyCDStringToClientFunc@4");
82 			bindFunc(cast(void**)&TwCopyCDStringToLibrary    , "_TwCopyCDStringToLibrary@8");
83 			bindFunc(cast(void**)&TwGetParam                 , "_TwGetParam@24");
84 			bindFunc(cast(void**)&TwSetParam                 , "_TwSetParam@24");
85 			bindFunc(cast(void**)&TwInit                     , "_TwInit@8");
86 			bindFunc(cast(void**)&TwTerminate                , "_TwTerminate@0");
87 			bindFunc(cast(void**)&TwDraw                     , "_TwDraw@0");
88 			bindFunc(cast(void**)&TwWindowSize               , "_TwWindowSize@8");
89 			bindFunc(cast(void**)&TwSetCurrentWindow         , "_TwSetCurrentWindow@4");
90 			bindFunc(cast(void**)&TwGetCurrentWindow         , "_TwGetCurrentWindow@0");
91 			bindFunc(cast(void**)&TwWindowExists             , "_TwWindowExists@4");
92 			bindFunc(cast(void**)&TwKeyPressed               , "_TwKeyPressed@8");
93 			bindFunc(cast(void**)&TwKeyTest                  , "_TwKeyTest@8");
94 			bindFunc(cast(void**)&TwMouseButton              , "_TwMouseButton@8");
95 			bindFunc(cast(void**)&TwMouseMotion              , "_TwMouseMotion@8");
96 			bindFunc(cast(void**)&TwMouseWheel               , "_TwMouseWheel@4");
97 			bindFunc(cast(void**)&TwGetLastError             , "_TwGetLastError@0");
98 			bindFunc(cast(void**)&TwHandleErrors             , "_TwHandleErrors@4");
99 			bindFunc(cast(void**)&TwEventWin                 , "_TwEventWin@16");
100 			bindFunc(cast(void**)&TwEventSDL                 , "_TwEventSDL@12");
101 			bindFunc(cast(void**)&TwEventMouseButtonGLFW     , "_TwEventMouseButtonGLFW@8");
102 			bindFunc(cast(void**)&TwEventKeyGLFW             , "_TwEventKeyGLFW@8");
103 			bindFunc(cast(void**)&TwEventCharGLFW            , "_TwEventCharGLFW@8");
104 			
105 			bindFunc(cast(void**)&TwEventMouseButtonGLUT , "TwEventMouseButtonGLUT");
106 			bindFunc(cast(void**)&TwEventMouseMotionGLUT , "TwEventMouseMotionGLUT");
107 			bindFunc(cast(void**)&TwEventKeyboardGLUT    , "TwEventKeyboardGLUT");
108 			bindFunc(cast(void**)&TwEventSpecialGLUT     , "TwEventSpecialGLUT");
109 //			bindFunc(cast(void**)&TwGLUTModifiersFunc    , "TwGLUTModifiersFunc");
110 //			bindFunc(cast(void**)&TwEventSFML            , "TwEventSFML");
111 			
112 			bindFunc(cast(void**)&TwEventMouseButtonGLFWcdecl , "TwEventMouseButtonGLFWcdecl");
113 			bindFunc(cast(void**)&TwEventKeyGLFWcdecl         , "TwEventKeyGLFWcdecl");
114 			bindFunc(cast(void**)&TwEventCharGLFWcdecl        , "TwEventCharGLFWcdecl");
115 			bindFunc(cast(void**)&TwEventMousePosGLFWcdecl    , "TwEventMousePosGLFWcdecl");
116         }
117     }
118     public
119     {
120         this()
121         {
122             super(libNames);
123         }
124     }
125 }
126 
127 __gshared DerelictAntTweakBarLoader DerelictAntTweakBar;
128 
129 shared static this()
130 {
131     DerelictAntTweakBar = new DerelictAntTweakBarLoader();
132 }
133 
134 shared static ~this()
135 {
136     DerelictAntTweakBar.unload();
137 }